<!DOCTYPE html>
<html>
<body>
<input type="text" id="str" placeholder="输入字符串" oninput="showChar()">
<input type="number" id="index" placeholder="输入位置" min="1" oninput="showChar()">
<input type="text" id="result" readonly>

<script>
function showChar() {
  const s = document.getElementById('str').value;
  const i = parseInt(document.getElementById('index').value) - 1;
  let char = '';
  if (i >= 0 && i < s.length) char = s.charAt(i);
  document.getElementById('result').value = char;
}
</script>
</body>
</html>